import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */




export const constantRoutes  = [

  //登录
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  //注册
  {
    path: '/register',
    component: () => import('@/views/register/index'),
    hidden: true			
  },


  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '个人信息', icon: 'el-icon-user' }
    }]
  },



  {
    path: '/examine',
    component: Layout,
    redirect: '/examine/user',
    name: 'Examine',
    meta: { title: '测评模块', icon: 'el-icon-edit-outline' },
    children: [
      {
        path: '/examination/:email',
        name: 'Examination',
        component: () => import('@/views/examination/list'),
        meta: { title: '考试', icon: 'el-icon-tickets' },
        hidden: true
        
      },
      {
        path: '/examination1',
        name: 'Examination1',
        component: () => import('@/views/examination/list1'),
        meta: { title: '测评表', icon: 'el-icon-tickets' },
        
      },
      {
        path: '/enroll',
        name: 'Enroll',
        component: () => import('@/views/examination/index'),
        meta: { title: '报名测评', icon: 'el-icon-s-platform' },
        
      },
      {
        path: '/inquire',
        name: 'Inquire',
        component: () => import('@/views/examination/form'),
        meta: { title: '评分查询', icon: 'el-icon-document-checked' },
        
      },
      
     
    ]
  },
  {
    path: '/summary',
    component: Layout,
    redirect: '/summary/user',
    name: 'Summary',
    meta: { title: '干部总结', icon: 'el-icon-folder' },
    children: [
      {
        path: '/summary/index',
        name: 'Index',
        component: () => import('@/views/summary/index'),
        meta: { title: '填写报告', icon: 'el-icon-edit' },
        
      },
      {
        path: '/summary/list',
        name: 'List',
        component: () => import('@/views/summary/list'),
        meta: { title: '报告管理', icon: 'el-icon-document' }
      },
      {
        path: '/summary/index/:id',
        name: 'List',
        component: () => import('@/views/summary/index'),
        meta: { title: '修改', icon: 'form' },
        hidden: true
      },
      
    ]
  },

  
  
  {
    path: '/example',
    component: Layout,
    redirect: '/example/user',
    name: 'Example',
    meta: { title: '权限模块', icon: 'el-icon-setting' },
    children: [
      {
        path: 'certification',
        name: 'Certification',
        component: () => import('@/views/certification/index'),
        meta: { title: '身份认证申请', icon: 'el-icon-s-custom' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: '申请进度', icon: 'el-icon-magic-stick' }
      }
    ]
  },
  {
    path: '/question1',
    component: Layout,
    redirect: '/question/user1',
    name: 'Question1',
    meta: { title: '管理员模块', icon: 'el-icon-folder-opened' },
    children: [
      
      {
        path: 'approve',
        name: 'Approve',
        component: () => import('@/views/approve/index'),
        meta: { title: '申请审批', icon: 'el-icon-chat-dot-square' }
      },
      {
        path: '/admin',
        component: () => import('@/views/examination/admin/index'),
        name: 'Admin',
        meta: { title: '测评指标', icon: 'el-icon-folder-opened' },
        children: [
          {
            path: '/list',
            name: 'List',
            component: () => import('@/views/question/list'),
            meta: { title: '指标查询', icon: 'el-icon-search' },
            
          },
          {
            path: '/index',
            name: 'increase',
            component: () => import('@/views/question/index'),
            meta: { title: '添加指标', icon: 'el-icon-folder-add' }
          },
          {
            path: '/index/:id',
            name: 'increase',
            component: () => import('@/views/question/index'),
            meta: { title: '修改题', icon: 'form' },
            hidden: true
          },
          
        ]
      },
      {
        path: '/summary/admin',
        component: () => import('@/views/summary/admin/index'),
        name: 'Admin11',
        meta: { title: '报告管理' , icon: 'el-icon-s-custom' },
        children: [
          {
            path: '/summary/getinfo',
            component: () => import('@/views/summary/admin/manage/list'),
            name: 'Getinfo',
            meta: { title: '报告管理' }
          },
          {
            path: '/summary/from/:id',
            name: 'List',
            component: () => import('@/views/summary/admin/analyse/index'),
            meta: { title: '查看', icon: 'form' },
            hidden: true
          },
        ]
      },
      {
        path: '/admin1',
        component: () => import('@/views/examination/admin/index'),
        name: 'Admin',
        meta: { title: '测评管理', icon: 'el-icon-s-custom' },
        children: [
          {
            path: '/getinfo',
            component: () => import('@/views/examination/admin/manage/index'),
            name: 'Getinfo',
            meta: { title: '考生信息' ,icon: 'el-icon-user-solid'}
          },
          {
            path: 'analyse',
            component: () => import('@/views/examination/admin/analyse/list'),
            name: 'Analyse',
            meta: { title: '统计分析', icon: 'el-icon-s-data'}
          },
        ]
      },
      {
        path: '/account ',
        name: 'Account ',
        component: () => import('@/views/account/list'),
        meta: { title: '账号管理', icon: 'el-icon-chat-dot-square' }
      },
      {
        path: '/userinfo ',
        name: 'Userinfo ',
        component: () => import('@/views/userinfo/list'),
        meta: { title: '信息管理', icon: 'el-icon-chat-dot-square' }
      },


      
    ]
  },

  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '密码修改', icon: 'form' }
      }
    ]
  },

  

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

function createRouter() {
  return new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })
  
}

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
